package com.bocloud.cmp.service.thread;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.fabric8.kubernetes.client.KubernetesClient;

/**
 * 滚动升级线程
 * 
 * @author zjm
 *
 */
public class RollingUpdateThread extends Thread {
	private static Logger logger = LoggerFactory.getLogger(RollingUpdateThread.class);
	private String namespace;
	private String rcName;
	private String image;
	private KubernetesClient client;

	public RollingUpdateThread(String namespace, String rcName, String image,
			KubernetesClient client) {
		super();
		this.namespace = namespace;
		this.rcName = rcName;
		this.image = image;
		this.client = client;
	}

	public void run() {
		try {
			client.replicationControllers().inNamespace(namespace).withName(rcName).rolling().updateImage(image);
		} catch (Exception e) {
			logger.warn("Rolling Update Exception:", e);
		}
	}

}
